package com.tianxiao.faas.common.result;

import com.tianxiao.faas.common.util.PageUtils;

import java.io.Serializable;


public class Result<T> implements Serializable {
    private static final long serialVersionUID = 5720985157430200739L;

    private T data;

    private Integer page = 1;

    private Integer pageSize = 10;

    private Integer totalCount = 0;

    private Integer totalPage = 1;

    private String msg;

    private boolean success;

    private String code;

    private Boolean isLogin = true;

    private String loginUrl;

    public Result(T data) {
        this.data = data;
        this.success = true;
    }

    public Result() {
    }

    public static Result builder() {
        return new Result();
    }

    public Result<T> data(T data) {
        this.data = data;
        return this;
    }

    public Result pageNo(Integer pageNo) {
        this.page = pageNo;
        return this;
    }

    public Result pageSize(Integer pageSize) {
        this.pageSize = pageSize;
        return this;
    }

    public Result totalCount(Integer totalCount) {
        this.totalCount = totalCount;
        return this;
    }

    public Result totalPage() {
        this.totalPage = PageUtils.totalPage(totalCount, pageSize);
        return this;
    }

    public Result msg(String msg) {
        this.msg = msg;
        return this;
    }

    public Result success(boolean success) {
        this.success = success;
        return this;
    }

    public Result code(String code) {
        this.code = code;
        return this;
    }

    public Result isLogin(boolean isLogin) {
        this.isLogin = isLogin;
        return this;
    }

    public Result loginUrl(String loginUrl) {
        this.loginUrl = loginUrl;
        return this;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public Integer getPage() {
        return page;
    }

    public void setPage(Integer pageNo) {
        this.page = pageNo;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public Integer getTotalCount() {
        return totalCount;
    }

    public void setTotalCount(Integer totalCount) {
        this.totalCount = totalCount;
    }

    public Integer getTotalPage() {
        return totalPage;
    }

    public void setTotalPage(Integer totalPage) {
        this.totalPage = totalPage;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public boolean getSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public Boolean getIsLogin() {
        return isLogin;
    }

    public void setIsLogin(Boolean login) {
        isLogin = login;
    }

    public String getLoginUrl() {
        return loginUrl;
    }

    public void setLoginUrl(String loginUrl) {
        this.loginUrl = loginUrl;
    }
}
